package wow.utils
{
	import mx.collections.ArrayList;
	
	import wow.data.Unit;
	
	public class UnitList extends ArrayList
	{
		public function UnitList(source:Array=null)
		{
			super(source);
		}
		
		public function get(index:int):Unit
		{
			return super.getItemAt(index) as Unit;
		}
		
		/**
		 * Obtient la première unité prête.
		 */
		public function getFirstReady():Unit
		{
			for (var index:int=0; index<this.length; index++)
			{
				var unit:Unit = this.get(index);
				if (unit.pret)
				{
					unit.active = true;
					return unit;
				}
			}
			
			return null;
		}
		
		public function setReadyAll():void
		{
			for (var index:int=0; index<this.length; index++)
			{
				this.get(index).pret = true;
			}
		}
	}
}